package com.omt.tarjimdinek.util;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;

import org.apache.log4j.Logger;
import org.omnifaces.eventlistener.DefaultPhaseListener;

/**
 * Simple phase listener logger. Convenient when learning/debugging JSF.
 * Must be activated in faces-config.xml
 */
public class LogPhaseListener extends DefaultPhaseListener {
    private static final long serialVersionUID = 1L;
    private static final Logger log = Logger.getLogger(LogPhaseListener.class);

    public LogPhaseListener() {
        super(PhaseId.ANY_PHASE);
    }

    @Override
    public void afterPhase(PhaseEvent event) {
        if (log.isDebugEnabled()) {
            log.debug(event.getPhaseId());
        }
    }

    @Override
    public void beforePhase(PhaseEvent event) {
        //    	if (log.isDebugEnabled()) {    	
        //    		log.debug(event.getPhaseId());
        //    	}
    }
}
